<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <ul>
      <li v-for="cate in cates" :key="cate.id">
        <img :src="cate.icon" alt="">
        <h4>{{cate.name}}</h4>
      </li>
    </ul>
    <hr>
    商品
    <ul>
      <li v-for="item in items" :key="item.id">
        <h5>
          {{item.name}}
        </h5>
        <img :src="item.pic" alt="">
      </li>
    </ul>
  </div>
  <script src="./vue.js"></script>
  <script src="./axios.js"></script>
  <script>
    const baseUrl = 'https://api.it120.cc/conner';
    const vm = new Vue({
      el: '#app',
      data: {
        cates: [],
        items: []
      },
      created(){
        this.fetchCates();
        this.fetchItems();
      },
      methods: {
        fetchItems(){
          axios({
            url: baseUrl+'/shop/goods/list/v2',
            method: 'post',
            data: {
              page: 1,
              pageSize: 10
            }
          }).then(res=> {
            if(res.data.code===0){
              this.items= res.data.data.result;
            }
          })
        
        },
        fetchCates(){
          // /shop/goods/category/all
          axios({
            url: baseUrl+'/shop/goods/category/all',
            method: 'get',
            params: {
              a:10,
              b:20
            }
          }).then(res=> {
            if(res.data.code===0){
              this.cates = res.data.data
            }
          })
        }
      }
    })

  </script>
</body>
</html>